local keysDown = {}


local function keyPressed(args)
	local key = args[1]

	gui.keyboard.pressed(key, args[2])
	
	if key == "escape" then
		if game.canTogglePause then
			game.isPaused = not game.isPaused
			--if we're in mid-intro, skip it
		elseif hook.Exists("introImage") or hook.Exists("introImageEnd") then
			hook.Remove("introImage")
			hook.Remove("introImageEnd")
			areas.titleScreen()
			--game.canTogglePause = true
		end
	end
	
	if not table.HasValue(keysDown, key) then
		table.insert(keysDown, key)
	end
	
	if table.HasValue(keysDown, "lalt") and table.HasValue(keysDown, "f4") then love.event.quit() end

end

hook.Add("keyPressed", "filterkeysp", keyPressed)

local function keyReleased(args)
	local key = args[1]
	
	for i, v in pairs(keysDown) do
		if key == v then
			table.remove(keysDown, i)
		end
	end
	
end

hook.Add("keyReleased", "filterkeysr", keyReleased)

function love.mousepressed( x, y, button )
	hook.Call("mousePressed", {x,y,button})
end

function love.mousereleased( x, y, button )
	hook.Call("mouseReleased", {x,y,button})
end